// 文章
import request from '@/utils/request'

/**
 * 获取文章列表信息
 * @param {*} data
 *
 * {
 *    channel_id:频道id
 *    timestamp：时间戳
 *    with_top:是否包含置顶 0不包含/1包含
 * }
 */
export const getArticles = (data) => {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params: data
  })
}

/**
 * 不感兴趣的文章
 * @param {*} articleId 文章id
 */
export const dislikeArticle = (articleId) => {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

/**
 * 反馈垃圾内容
 * @param {*} articleId  文章编号
 * @param {*} type  举报类型
 */
export const reportArticle = (articleId, type) => {
  return request({
    url: '/app/v1_0/article/reports',
    method: 'POST',
    data: {
      target: articleId,
      type: type
    }
  })
}

/**
 * 获取文章详情
 * @param {*} articleId 文章id
 */
export const getArticleDetail = (articleId) => {
  return request({
    url: '/app/v1_0/articles/' + articleId,
    method: 'GET'
  })
}

/**
 * 取消点赞
 * @param {*} articleId 文章编号
 */
export const deleteLike = (articleId) => {
  return request({
    method: 'DELETE',
    url: '/app/v1_0/article/likings/' + articleId
  })
}

/**
 * 给文章点赞
 * @param {*} articleId 文章编号
 */
export const addLike = (articleId) => {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

/**
 * 取消点赞
 * @param {*} articleId 文章编号
 */
export const deleteDisLike = (articleId) => {
  return request({
    method: 'DELETE',
    url: '/app/v1_0/article/dislikes/' + articleId
  })
}

/**
 * 给文章点赞
 * @param {*} articleId 文章编号
 */
export const addDisLike = (articleId) => {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}
